<template>
    <a-drawer
        :title="formData.wfSendRoundInfoId ? '编辑传阅记录' : '增加传阅记录'"
        :width="600"
        :visible="visible"
        :destroy-on-close="true"
        :footer-style="{ textAlign: 'right' }"
        @close="onClose"
    >
        <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
            <a-form-item label="WORKFLOW_MESSAGES_ID：" name="workflowMessagesId">
                <a-input v-model:value="formData.workflowMessagesId" placeholder="请输入WORKFLOW_MESSAGES_ID" allow-clear />
            </a-form-item>
            <a-form-item label="MESSAGE_WORKITEM_ID：" name="messageWorkitemId">
                <a-input v-model:value="formData.messageWorkitemId" placeholder="请输入MESSAGE_WORKITEM_ID" allow-clear />
            </a-form-item>
            <a-form-item label="MESSAGE_TRACK_ID：" name="messageTrackId">
                <a-input v-model:value="formData.messageTrackId" placeholder="请输入MESSAGE_TRACK_ID" allow-clear />
            </a-form-item>
            <a-form-item label="PROCESS_INSTANCE_ID：" name="processInstanceId">
                <a-input v-model:value="formData.processInstanceId" placeholder="请输入PROCESS_INSTANCE_ID" allow-clear />
            </a-form-item>
            <a-form-item label="PRO_FORM_NO：" name="proFormNo">
                <a-input v-model:value="formData.proFormNo" placeholder="请输入PRO_FORM_NO" allow-clear />
            </a-form-item>
            <a-form-item label="PRO_FORM_NAME：" name="proFormName">
                <a-input v-model:value="formData.proFormName" placeholder="请输入PRO_FORM_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="WF_SECTION_ID：" name="wfSectionId">
                <a-input v-model:value="formData.wfSectionId" placeholder="请输入WF_SECTION_ID" allow-clear />
            </a-form-item>
            <a-form-item label="WF_SECTION_NAME：" name="wfSectionName">
                <a-input v-model:value="formData.wfSectionName" placeholder="请输入WF_SECTION_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGE_TYPE：" name="wfMessageType">
                <a-input v-model:value="formData.wfMessageType" placeholder="请输入WF_MESSAGE_TYPE" allow-clear />
            </a-form-item>
            <a-form-item label="DJ_AUDIT_STATUS：" name="djAuditStatus">
                <a-input v-model:value="formData.djAuditStatus" placeholder="请输入DJ_AUDIT_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="DATE_PRIMARYKEY_ID：" name="datePrimarykeyId">
                <a-input v-model:value="formData.datePrimarykeyId" placeholder="请输入DATE_PRIMARYKEY_ID" allow-clear />
            </a-form-item>
            <a-form-item label="SEND_PERSON_PARTYID：" name="sendPersonPartyid">
                <a-input v-model:value="formData.sendPersonPartyid" placeholder="请输入SEND_PERSON_PARTYID" allow-clear />
            </a-form-item>
            <a-form-item label="SEND_PERSON_CODE：" name="sendPersonCode">
                <a-input v-model:value="formData.sendPersonCode" placeholder="请输入SEND_PERSON_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="SEND_PERSON_NAME：" name="sendPersonName">
                <a-input v-model:value="formData.sendPersonName" placeholder="请输入SEND_PERSON_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_PARTYID：" name="receivePersonPartyid">
                <a-input v-model:value="formData.receivePersonPartyid" placeholder="请输入RECEIVE_PERSON_PARTYID" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_CODE：" name="receivePersonCode">
                <a-input v-model:value="formData.receivePersonCode" placeholder="请输入RECEIVE_PERSON_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_NAME：" name="receivePersonName">
                <a-input v-model:value="formData.receivePersonName" placeholder="请输入RECEIVE_PERSON_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="READ_STATE：" name="readState">
                <a-input v-model:value="formData.readState" placeholder="请输入READ_STATE" allow-clear />
            </a-form-item>
            <a-form-item label="READ_TIME：" name="readTime">
                <a-date-picker v-model:value="formData.readTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择READ_TIME" style="width: 100%" />
            </a-form-item>
            <a-form-item label="SEND_TIME：" name="sendTime">
                <a-date-picker v-model:value="formData.sendTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择SEND_TIME" style="width: 100%" />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_DEPT_CODE：" name="receivePersonDeptCode">
                <a-input v-model:value="formData.receivePersonDeptCode" placeholder="请输入RECEIVE_PERSON_DEPT_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_DEPT_ID：" name="receivePersonDeptId">
                <a-input v-model:value="formData.receivePersonDeptId" placeholder="请输入RECEIVE_PERSON_DEPT_ID" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_DEPT_NAME：" name="receivePersonDeptName">
                <a-input v-model:value="formData.receivePersonDeptName" placeholder="请输入RECEIVE_PERSON_DEPT_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_COMPANY_CODE：" name="receivePersonCompanyCode">
                <a-input v-model:value="formData.receivePersonCompanyCode" placeholder="请输入RECEIVE_PERSON_COMPANY_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_COMPANY_ID：" name="receivePersonCompanyId">
                <a-input v-model:value="formData.receivePersonCompanyId" placeholder="请输入RECEIVE_PERSON_COMPANY_ID" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_COMPANY_NAME：" name="receivePersonCompanyName">
                <a-input v-model:value="formData.receivePersonCompanyName" placeholder="请输入RECEIVE_PERSON_COMPANY_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="SEND_MARK：" name="sendMark">
                <a-input v-model:value="formData.sendMark" placeholder="请输入SEND_MARK" allow-clear />
            </a-form-item>
            <a-form-item label="SYS_PARTY_CODE：" name="sysPartyCode">
                <a-input v-model:value="formData.sysPartyCode" placeholder="请输入SYS_PARTY_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="USABLE_STATUS：" name="usableStatus">
                <a-input v-model:value="formData.usableStatus" placeholder="请输入USABLE_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="CREATE_DATE：" name="createDate">
                <a-date-picker v-model:value="formData.createDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择CREATE_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="CREATE_IP：" name="createIp">
                <a-input v-model:value="formData.createIp" placeholder="请输入CREATE_IP" allow-clear />
            </a-form-item>
            <a-form-item label="CREATE_USER_ID：" name="createUserId">
                <a-input v-model:value="formData.createUserId" placeholder="请输入CREATE_USER_ID" allow-clear />
            </a-form-item>
            <a-form-item label="MODIFY_DATE：" name="modifyDate">
                <a-date-picker v-model:value="formData.modifyDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择MODIFY_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="MODIFY_IP：" name="modifyIp">
                <a-input v-model:value="formData.modifyIp" placeholder="请输入MODIFY_IP" allow-clear />
            </a-form-item>
            <a-form-item label="MODIFY_USER_ID：" name="modifyUserId">
                <a-input v-model:value="formData.modifyUserId" placeholder="请输入MODIFY_USER_ID" allow-clear />
            </a-form-item>
            <a-form-item label="ORDER_CODE：" name="orderCode">
                <a-input v-model:value="formData.orderCode" placeholder="请输入ORDER_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE1：" name="attribute1">
                <a-input v-model:value="formData.attribute1" placeholder="请输入ATTRIBUTE1" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE2：" name="attribute2">
                <a-input v-model:value="formData.attribute2" placeholder="请输入ATTRIBUTE2" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE3：" name="attribute3">
                <a-input v-model:value="formData.attribute3" placeholder="请输入ATTRIBUTE3" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE4：" name="attribute4">
                <a-input v-model:value="formData.attribute4" placeholder="请输入ATTRIBUTE4" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE5：" name="attribute5">
                <a-input v-model:value="formData.attribute5" placeholder="请输入ATTRIBUTE5" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_CUMAIL：" name="receivePersonCumail">
                <a-input v-model:value="formData.receivePersonCumail" placeholder="请输入RECEIVE_PERSON_CUMAIL" allow-clear />
            </a-form-item>
            <a-form-item label="RECEIVE_PERSON_OU：" name="receivePersonOu">
                <a-input v-model:value="formData.receivePersonOu" placeholder="请输入RECEIVE_PERSON_OU" allow-clear />
            </a-form-item>
            <a-form-item label="SEND_PERSON_CUMAIL：" name="sendPersonCumail">
                <a-input v-model:value="formData.sendPersonCumail" placeholder="请输入SEND_PERSON_CUMAIL" allow-clear />
            </a-form-item>
            <a-form-item label="SEND_PERSON_OU：" name="sendPersonOu">
                <a-input v-model:value="formData.sendPersonOu" placeholder="请输入SEND_PERSON_OU" allow-clear />
            </a-form-item>
            <a-form-item label="WORKFLOW_NAME：" name="workflowName">
                <a-input v-model:value="formData.workflowName" placeholder="请输入WORKFLOW_NAME" allow-clear />
            </a-form-item>
        </a-form>
        <template #footer>
            <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
            <a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
        </template>
    </a-drawer>
</template>

<script setup name="flwSendRoundInfoForm">
    import { cloneDeep } from 'lodash-es'
    import { required } from '@/utils/formRules'
    import flwSendRoundInfoApi from '@/api/biz/flwSendRoundInfoApi'
    // 抽屉状态
    const visible = ref(false)
    const emit = defineEmits({ successful: null })
    const formRef = ref()
    // 表单数据
    const formData = ref({})
    const submitLoading = ref(false)

    // 打开抽屉
    const onOpen = (record) => {
        visible.value = true
        if (record) {
            let recordData = cloneDeep(record)
            formData.value = Object.assign({}, recordData)
        }
    }
    // 关闭抽屉
    const onClose = () => {
        formRef.value.resetFields()
        formData.value = {}
        visible.value = false
    }
    // 默认要校验的
    const formRules = {
    }
    // 验证并提交数据
    const onSubmit = () => {
        formRef.value
            .validate()
            .then(() => {
                submitLoading.value = true
                const formDataParam = cloneDeep(formData.value)
                flwSendRoundInfoApi
                    .flwSendRoundInfoSubmitForm(formDataParam, !formDataParam.wfSendRoundInfoId)
                    .then(() => {
                        onClose()
                        emit('successful')
                    })
                    .finally(() => {
                        submitLoading.value = false
                    })
            })
    }
    // 抛出函数
    defineExpose({
        onOpen
    })
</script>
